
<template>
  <div class="app-dialog active-config-main">
    <template v-if="hasPosterRef">
      <template v-if="boo.isFlash">
        <active-poster ref="posterRef" :active-id="currentItem.id"/>
      </template>
    </template>
    <el-form
      class="form-content"
      ref="active-form" label-position="left"
      :model="currentItem" v-loading="boo.loading"
      label-width="120px">
      <div class="form-title flex-between">
        <span class="title-txt">活动信息</span>
        <el-button :loading="boo.isPrice" type="primary" size="small" @click="submit('active-form')">发布活动</el-button>
      </div>
      <el-form-item class="form-content-item" label="活动类型">
        <el-select v-model="currentItem.activityTypeId" placeholder="请选择" 
        @change="activeTypeChange" :disabled="activeTypeDisabled">
          <el-option v-for="(option, index) in getDictItem('activityType')" :key="index" 
          :label="option.dictLabel" :value="option.dictValue"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item v-if="activeFiles.activityName"
      class="form-content-item" label="活动名称" prop="activityName"
      :rules="{ required: true, message: '活动名称不能为空', trigger: 'blur'}">
        <el-input :disabled="$route.query['id'] ? true : false" v-model="currentItem.activityName" placeholder="请输入"></el-input>
      </el-form-item>
      <el-form-item v-if="activeFiles.acceptingUnit" class="form-content-item" label="接收单位"
      :rules="{ required: true, message: '接收单位不能为空', trigger: 'blur'}" prop="acceptingUnit">
        <el-input v-model="currentItem.acceptingUnit" placeholder="太平洋保险"></el-input>
      </el-form-item>
      <el-form-item v-if="activeFiles.serveTypeIds" label="服务内容" prop="serveTypeIds"
      :rules="{ validator: validateFwnr, required: true, trigger: 'change'}">
        <div class="package-model-container ">
          <div class="package-desc flex-normal">
            <i class="desc-icon el-icon-info"></i>
            <span class="desc-txt">根据套餐内容计算，无需手工输入</span>
          </div>
          <div class="model-main-container">
            <div class="model-tab-container flex-between">
              <div class="model-tab-content flex-normal">
                <div v-for="(tab, idx) in tabFwList" :key="idx" 
                  :class="['tab-item flex-center', currentFwTab.name == tab.name && 'active']"
                  @click="tabFwChange(tab)">
                  <span class="tab-txt">{{tab.label}}</span>
                </div>
              </div>
              <div class="mdoel-btn-content flex-center">
                <span class="btn-txt" style="color: #333" @click="showFwDialog" :loading="glfwProps.queryGl">管理服务</span>
              </div>
            </div>
            <div class="" v-if="currentFwTab.name">
              <el-scrollbar class="model-main-content">      
                <div class="item flex-between" v-for="(item) in currentFwTab.list" :key="item.id">
                  <div class="item-image">
                    <img class="image" :src="item.serveImg" >
                  </div>
                  <div class="item-content flex-column">
                    <span class="item-label">{{item.serveName}}</span>
                    <span class="item-type">{{item.serveDetails}} * {{ item.itemNum }}</span>
                    <div class="item-more flex-normal">
                      <span class="i-desc">市场单价：{{item.price || '0.00'}}</span>
                      <span class="i-desc">核销价：{{item.writeOffFee || '0.00'}}</span>
                    </div>
                  </div>
                  <div :class="['item-action flex-normal', item.isChecked && 'active']"
                  @click="actionFwItem(item)">
                    <span class="action-icon car-common-icon">&#xe663;</span>
                    <span class="action-txt">选择</span>
                  </div>
                </div>
              </el-scrollbar>
            </div>
            <div class="model-selected-content flex-column">
              <span class="select-label">已选服务</span>
              <div class="select-content">
                <el-table :data="tableData" height="300"
                  style="width: 100%;">
                  <el-table-column prop="serveTypeId" label="服务类型">
                    <template slot-scope="{row}">
                      {{ resetGlfwType(glfwProps.dictTypeList, row.serveTypeId) }}
                    </template>
                  </el-table-column>
                  <el-table-column prop="serveName" label="服务名称"></el-table-column>
                  <el-table-column prop="serveDetails" label="服务内容"></el-table-column>
                  <el-table-column prop="itemNum" label="服务次数">
                    <template slot-scope="{row}">
                      <div>{{ row.itemNum || '0' }}</div>
                    </template>
                  </el-table-column>
                  <el-table-column
                    v-if="shopType == 4"
                    label="用户优惠价"
                    align="center"
                    prop="discountedPrice">
                    <template slot-scope="{row}"> 
                      {{ row.discountedPrice || '0.00' }}
                    </template>
                  </el-table-column>
                  <el-table-column prop="price" label="市场单价"></el-table-column>
                  <el-table-column prop="writeOffFee" label="核销单价"></el-table-column>
                  <el-table-column v-if="currentItem.activityTypeId == 7" prop="probability" label="中奖概率">
                    <template slot-scope="{row}">
                      <el-input-number v-model="row.probability"
                      controls-position="right" :precision="2" :step="0.1"
                      :min="0" :max="1"></el-input-number>
                    </template>
                  </el-table-column>
                  <el-table-column prop="total" label="总计"></el-table-column>
                </el-table>
                <div class="sums-content flex-column">
                  <!-- <div class="sums-item flex-normal">
                    <span class="sums-label desc">市场单价</span>
                    <span class="sums-val">{{sumsObj.marketPrice}}</span>
                  </div> -->
                  <div class="sums-item flex-normal">
                    <span class="sums-label">优惠总计</span>
                    <span class="sums-val error">{{sumsObj.preferentialPrice}}</span>
                  </div>
                  <div class="sums-item flex-normal">
                    <span class="sums-label">核销总计</span>
                    <span class="sums-val">{{sumsObj.writeOffPrice}}</span>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </el-form-item>

      <el-form-item v-if="activeFiles.number" class="form-content-item" label="活动份数"
        prop="number" :rules="[
          { required: true, message: '活动份数不能为空', trigger: 'blur'},
          { validator: validateHdfs, trigger: 'blur'}
        ]">
        <div class="num-form-content flex-normal">
          <el-input class="num-form" v-model="currentItem.number" placeholder="输入数量"></el-input>
        </div>
      </el-form-item>
      <el-form-item v-if="activeFiles.activityTime" class="form-content-item" label="活动时间"
        prop="activityTime" :rules="[
          { required: true,  validator: validateHdSJ, trigger: 'change'}
        ]">
        <div class="time-date-select-container flex-normal">
          <div class="form-content-row flex-normal">
            <div class="item-col">
              <el-date-picker
                v-model="currentItem.startingTime"
                type="date" value-format="yyyy-MM-dd"
                placeholder="选择开始日期">
              </el-date-picker>
            </div>
            <div class="item-col">
              <span class="col-txt">至</span>
            </div>
            <div class="item-col">
              <el-date-picker
                v-model="currentItem.endTime"
                type="date" value-format="yyyy-MM-dd"
                placeholder="选择结束日期">
              </el-date-picker>
            </div>
          </div>
        </div>
      </el-form-item>

      <el-form-item v-if="activeFiles.periodOfValidity" class="form-content-item" label="卡券有效期"
        prop="closingDate" :rules="[
          { required: true,  validator: validateKqyxq, trigger: 'change'}
        ]">
        <div class="form-content-row flex-normal">
          <div class="item-col col-time">
            <el-date-picker value-format="yyyy-MM-dd"
              v-model="currentItem.closingDate"
              type="date" @change="dataPickerChange($event, 'closingDate')"
              placeholder="截止日期">
            </el-date-picker>
          </div>
          <div class="item-col">
            <el-checkbox v-model="currentItem.whetherToClosingDate"
            @change="checkboxChange($event, 'whetherToClosingDate')">长期有效</el-checkbox>
          </div>
        </div>
      </el-form-item>
      <el-form-item v-if="activeFiles.purchaseRestrictions && currentItem.activityTypeId != 7" class="form-content-item" 
        label="购买限制"
        prop="purchaseRestrictions" :rules="[
          { required: false,  validator: validateGmxz, trigger: 'change'}
        ]">
        <div class="form-content-row flex-normal">
          <div class="item-col">
            <el-checkbox v-model="currentItem.limitation"></el-checkbox>
          </div>
          <div class="item-col">
            <span class="col-txt">每用户仅可购买</span>
          </div> 
          <div class="item-col col-num">
            <el-input v-model="currentItem.emptionRestrict" placeholder="输入数量"></el-input>
          </div>
          <div class="item-col">
            <span class="col-txt">份</span>
          </div> 
        </div>
      </el-form-item>
      <el-form-item v-if="activeFiles.purchaseRestrictions && currentItem.activityTypeId == 7" class="form-content-item" 
        label="抽奖限制"
        prop="emptionRestrict" :rules="[
          { required: true, message: '抽奖数目不能为空', trigger: 'change'}
        ]">
        <div class="form-content-row flex-normal">
          <div class="item-col">
            <span class="col-txt">每用户仅可抽奖</span>
          </div> 
          <div class="item-col col-num">
            <el-input v-model="currentItem.emptionRestrict" placeholder="输入数量"></el-input>
          </div>
          <div class="item-col">
            <span class="col-txt">次</span>
          </div> 
        </div>
      </el-form-item>
      <el-form-item v-if="activeFiles.sharedRedEnvelope" class="form-content-item" label="分享红包"
        prop="sharedRedEnvelope" :rules="[
          { required: false,  validator: validateFxhb, trigger: 'change'}
        ]">
        <div class="form-content-row flex-normal">
          <div class="item-col">
            <span class="col-label">奖励条件</span>
          </div>
          <div class="item-col">
            <el-radio-group v-model="currentItem.rewardCondition">
              <el-radio :label="1">已购客户</el-radio>
              <el-radio :label="0">所有客户</el-radio>
            </el-radio-group>
          </div>
        </div>
        <div class="form-content-row flex-normal">
          <div class="item-col">
            <el-checkbox v-model="currentItem.whetherToShare"></el-checkbox>
          </div>
          <div class="item-col">
            <span class="col-txt">分享成交后后，得</span>
          </div> 
          <div class="item-col">
            <el-input class="num-form" v-model="currentItem.completeIncome" placeholder="0.00"></el-input>
          </div>
          <div class="item-col">
            <span class="col-txt">元</span>
          </div> 
          <div class="item-col">
            <div class="warning-desc flex-normal">
              <i class="desc-icon el-icon-info"></i>
              <span class="desc-txt">该费用将从活动收益中扣除</span>
            </div>
          </div>
        </div>
      </el-form-item>
      <el-form-item v-if="activeFiles.activeOptions" class="form-content-item" label="激活选项" 
        prop="activeOptions" :rules="[
          { required: true,  validator: validateJhxx, trigger: 'change'}
        ]">
        <div class="form-content-row flex-normal">
          <div class="item-col">
            <span class="col-label">到店激活</span>
          </div>
          <div class="item-col">
            <el-radio-group v-model="currentItem.shopActivation">
              <el-radio :label="0">是</el-radio>
              <el-radio :label="1">否</el-radio>
            </el-radio-group>
          </div>
        </div>
        <div class="form-content-row flex-normal">
          <div class="item-col">
            <span class="col-label">激活截止日期</span>
          </div>
          <div class="item-col col-time">
            <el-date-picker
              v-model="currentItem.activationClosingDate"
              type="date"
              placeholder="选择时间">
            </el-date-picker>
          </div>
        </div>
        <!-- <div class="form-content-row flex-normal">
          <div class="item-col">
            <span class="col-label">未激活券码</span>
          </div>
          <div class="item-col">
            <el-radio-group v-model="currentItem.notActivationCode">
              <el-radio :label="1">自动退款取消</el-radio>
              <el-radio :label="0">到期前系统自动激活</el-radio>
            </el-radio-group>
          </div>
        </div> -->
        <div class="form-content-row flex-normal" v-if="currentItem.shopActivation != 1">
          <div class="item-col">
            <span class="col-label">未激活券码</span>
          </div>
          <div class="item-col">
            <el-radio-group v-model="currentItem.activationStatus">
              <el-radio :label="1">到期未激活自动退款</el-radio>
              <el-radio :label="2">到期未激活自动激活</el-radio>
            </el-radio-group>
          </div>
        </div>
      </el-form-item>
      <el-form-item v-if="activeFiles.whoWillBearTheCost" class="form-content-item" label="技术服务费"
        prop="whoWillBearTheCost" :rules="[
          { required: true,  validator: validateJsfwf, trigger: 'change'}
        ]">
        <div class="form-content-row flex-normal">
          <div class="item-col">
            <el-radio-group v-model="currentItem.skillServeFee">
              <el-radio :label="0">商户承担</el-radio>
              <el-radio :label="1">用户承担</el-radio>
            </el-radio-group>
          </div>
          <div class="item-col">
            <div class="warning-desc flex-normal">
              <i class="desc-icon el-icon-info"></i>
              <span class="desc-txt">该订单技术服务费为{{currentItem.serviceFee || '0.00'}}元</span>
            </div>
          </div>
        </div>
      </el-form-item>
      <el-form-item v-if="activeFiles.targetedUsers" label="定向用户"
        prop="acddUsers" :rules="[
          { required: false,  message: '请设置定向用户', trigger: 'change'}
        ]">
        <div class="form-content-row">
          <div class="user-list-title flex-between">
            <span class="title-label">用户列表({{userList.length}})</span>
            <div class="title-btn-content flex-normal">
              <el-button type="primary" size="small" @click="exportUserTmp">下载模板</el-button>
              <el-button type="primary" size="small" @click="importUser">导入</el-button>
              <el-button type="primary" size="small" @click="addUser">添加用户</el-button>
            </div>
          </div>
          <div class="user-list app-table-container">
            <template v-if="currentItem.activityTypeId != 6">
              <template v-if="currentItem.activityTypeId == 2">
                <el-table width="100%" v-loading="boo.loading" :data="userList" height="300">
                  <el-table-column
                    label="开始时间"
                    align="center">
                    <template slot-scope="{row}">
                      <el-date-picker
                        :disabled="row.useStatus != 1 ? true: false"
                        v-model="row.orderTimeStart"
                        type="date"  size="small"
                        placeholder="选择日期">
                      </el-date-picker>
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="购买有效期(天)"
                    align="center">
                    <template slot-scope="{row}">
                      <el-input-number size="small"
                      v-model="row.payValidDay" 
                      :disabled="row.useStatus != 1 ? true: false"
                      controls-position="right"
                      :min="1"></el-input-number>
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="手机号"
                    align="center">
                    <template slot-scope="{row}">
                      <el-input :disabled="row.useStatus != 1 ? true: false" v-model="row.phone" size="small"></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="姓名"
                    align="center">
                    <template slot-scope="{row}">
                      <el-input :disabled="row.useStatus != 1 ? true: false" v-model="row.name" size="small"></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="车牌号"
                    align="center">
                    <template slot-scope="{row}">
                      <el-input :disabled="row.useStatus != 1 ? true: false" v-model="row.licensePlate" size="small"></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="卡券有效期"
                    align="center">
                    <template slot-scope="{row}">
                      <el-select :disabled="row.useStatus != 1 ? true: false" v-model="row.orderPeriodValidity" placeholder="请选择">
                        <el-option label="1个月" :value="1"></el-option>
                        <el-option label="3个月" :value="2"></el-option>
                        <el-option label="6个月" :value="3"></el-option>
                        <el-option label="1年" :value="4"></el-option>
                        <el-option label="2年" :value="5"></el-option>
                        <el-option label="3年" :value="6"></el-option>
                      </el-select>
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="操作"
                    align="center" width="100"
                    class-name="small-padding fixed-width"
                  >
                    <template slot-scope="{row, $index}">
                      <el-button
                        size="mini" :disabled="row.useStatus != 1 ? true: false"
                        type="text" @click="removeTargetUser($index)"
                        icon="el-icon-del"
                        >移除</el-button
                      >
                    </template>
                  </el-table-column>
                </el-table>
              </template>
              <template v-else-if="currentItem.activityTypeId == 5">
                <el-table width="100%" v-loading="boo.loading" :data="userList" height="300">
                  <el-table-column
                    label="手机号"
                    align="center">
                    <template slot-scope="{row}">
                      <el-input :disabled="row.useStatus != 1 ? true: false" v-model="row.phone" size="small"></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="姓名"
                    align="center">
                    <template slot-scope="{row}">
                      <el-input :disabled="row.useStatus != 1 ? true: false" v-model="row.name" size="small"></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="车牌号"
                    align="center">
                    <template slot-scope="{row}">
                      <el-input :disabled="row.useStatus != 1 ? true: false" v-model="row.licensePlate" size="small"></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="车架号"
                    align="center">
                    <template slot-scope="{row}">
                      <el-input :disabled="row.useStatus != 1 ? true: false" v-model="row.vehicleIdentificationNumber" size="small"></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="备注"
                    align="center">
                    <template slot-scope="{row}">
                      <el-input :disabled="row.useStatus != 1 ? true: false" v-model="row.commentContent" size="small"></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="操作"
                    align="center" width="100"
                    class-name="small-padding fixed-width"
                  >
                    <template slot-scope="{row, $index}">
                      <el-button
                        size="mini" :disabled="row.useStatus != 1 ? true: false"
                        type="text" @click="removeTargetUser($index)"
                        icon="el-icon-del"
                        >移除</el-button
                      >
                    </template>
                  </el-table-column>
                </el-table>
              </template>
              <template v-else>
                <el-table width="100%" v-loading="boo.loading" :data="userList" height="300">
                  <el-table-column
                    label="手机号"
                    align="center">
                    <template slot-scope="{row}">
                      <el-input :disabled="row.useStatus != 1 ? true: false" v-model="row.phone" size="small"></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="姓名"
                    align="center">
                    <template slot-scope="{row}">
                      <el-input :disabled="row.useStatus != 1 ? true: false" v-model="row.name" size="small"></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="车牌号"
                    align="center">
                    <template slot-scope="{row}">
                      <el-input :disabled="row.useStatus != 1 ? true: false" v-model="row.licensePlate" size="small"></el-input>
                    </template>
                  </el-table-column>
                  <el-table-column
                    label="操作"
                    align="center" width="100"
                    class-name="small-padding fixed-width"
                  >
                    <template slot-scope="{row, $index}">
                      <el-button
                        size="mini" :disabled="row.useStatus != 1 ? true: false"
                        type="text" @click="removeTargetUser($index)"
                        icon="el-icon-del"
                        >移除</el-button
                      >
                    </template>
                  </el-table-column>
                </el-table>
              </template>
            </template>
            <template v-if="currentItem.activityTypeId == 6">
              <el-table width="100%" v-loading="boo.loading" :data="userList" height="300">
                <el-table-column
                  label="手机号"
                  align="center">
                  <template slot-scope="{row}">
                    <el-input v-model="row.phone" size="small"></el-input>
                  </template>
                </el-table-column>
                <el-table-column
                  label="姓名"
                  align="center">
                  <template slot-scope="{row}">
                    <el-input v-model="row.name" size="small"></el-input>
                  </template>
                </el-table-column>
                <el-table-column
                  label="红包金额"
                  align="center">
                  <template slot-scope="{row}">
                    <el-input-number v-model="row.balance" 
                    :precision="2" :step="0.1" size="small"
                    controls-position="right" 
                    :min="0"
                    @change="handleChange"></el-input-number>
                  </template>
                </el-table-column>
                <el-table-column
                  label="车牌号"
                  align="center">
                  <template slot-scope="{row}">
                    <el-input v-model="row.licensePlate" size="small"></el-input>
                  </template>
                </el-table-column>
                <el-table-column
                  label="商业险保单号"
                  align="center"
                  :show-overflow-tooltip="true">
                  <template slot-scope="{row}">
                    <!-- <div :contenteditable="true" @blur="rowTxtChange($event, row)">
                      {{ row.insureCode || '' }}
                    </div> -->
                    <el-input v-model="row.insureCode" size="small"></el-input>
                  </template>
                </el-table-column>
                <el-table-column
                  label="操作"
                  align="center" width="100"
                  class-name="small-padding fixed-width"
                >
                  <template slot-scope="{$index}">
                    <el-button
                      size="mini"
                      type="text" @click="removeTargetUser($index)"
                      icon="el-icon-del"
                      >移除</el-button
                    >
                  </template>
                </el-table-column>
              </el-table>
            </template>
          </div>
        </div>
      </el-form-item>
      <el-form-item v-if="activeFiles.shopIds" label="适用商户"
        prop="suitShopIds" :rules="[
          { required: true,  validator: validateSysh, trigger: 'change'}
        ]">
        <template v-if="shopType == 4">
          <div class="form-content-row flex-normal">
            <div class="item-col">
              <el-checkbox-group v-model="currentItem.shopPool">
                <el-checkbox v-for="(checkbox) in getDictItem('shopPool')" :key="checkbox.dictValue" 
                :label="checkbox.dictValue">{{checkbox.dictLabel}}</el-checkbox>
              </el-checkbox-group>
            </div>
          </div>
        </template>
        <template v-else>
          <div class="form-content-row flex-normal">
            <div class="item-col">
              <el-checkbox-group v-model="currentItem.shopPool" @change="queryShopListByPool('change')">
                <el-checkbox v-for="(checkbox) in getDictItem('shopPool')" :key="checkbox.dictValue" 
                :label="checkbox.dictValue">{{checkbox.dictLabel}}</el-checkbox>
              </el-checkbox-group>
            </div>
          </div>
          <div class="form-content-row flex-normal">
            <div class="storeList-model-container">
              <div class="store-list-title-container flex-between">
                <div class="title-content flex-center">
                  <span class="title-txt" style="margin-right: 10px;">商家列表（{{shopList.length}}家）</span>
                  <el-checkbox v-model="boo.shopAll" @change="selectShopAll">全选</el-checkbox>
                </div>
                <div class="search-content flex-center">
                  <el-input v-model="searchProp.text" filterable
                    remote reserve-keyword placeholder="请输入关键词"
                    @input="remoteMethod">
                  </el-input>
                </div>
              </div>
              <el-scrollbar class="store-list-main">
                <div :class="['item flex-between', item.isChecked && 'active']"
                  v-for="item in searchProp.options" :key="item.id">
                  <div class="item-content flex-normal">
                    <span class="item-label ellipsis-1">{{item.shopName}}</span>
                    <span class="item-desc ellipsis-1">{{item.shopAddress}}</span>
                  </div>
                  <div :class="['item-action flex-normal', item.isChecked && 'active']"
                    @click="actionShopItem(item)">
                    <span class="action-icon car-common-icon">&#xe663;</span>
                    <span class="action-txt">选择</span>
                  </div>
                </div>
              </el-scrollbar>
            </div>
          </div>
        </template>
      </el-form-item>
      <el-form-item v-if="activeFiles.clusteringConditions" class="form-content-item" label="成团条件"
        prop="clusteringConditions" :rules="[
          { required: true,  validator: validateCttj, trigger: 'change'}
        ]">
        <div class="form-content-row flex-column">
          <el-radio v-model="currentItem.clusteringCondition" :label="0" @change="radioChange($event, 'clusteringCondition')">阶梯团购</el-radio>
          <div class="ct-list" v-if="currentItem.clusteringCondition == '0' && currentItem['acddGroupBuyings']">
            <div class="ct-item flex-normal" v-for="(it, idx) in currentItem['acddGroupBuyings']" :key="idx">
              <div class="item-col max-mix">
                <el-input v-model="it.miniValue" placeholder="输入数量"></el-input>
              </div>
              <div class="item-col">
                <span class="col-txt">至</span>
              </div>
              <div class="item-col max-mix">
                <el-input v-model="it.maxValue" placeholder="输入数量"></el-input>
              </div>
              <div class="item-col">
                <span class="col-txt">时，价格为</span>
              </div>
              <div class="item-col col-money">
                <el-input v-model="it.price" placeholder="输入金额">
                  <span class="col-txt" slot="suffix">元</span>
                </el-input>
              </div>
              <div class="item-action flex-normal">
                <span class="action-btn el-icon-circle-plus" @click="addGroupBuy"></span>
                <span class="action-btn el-icon-remove" @click="removeGroupBuy(idx)" v-if="idx !== 0"></span>
              </div>
            </div>
          </div>
        </div>
        <div class="form-content-row flex-column">
          <el-radio v-model="currentItem.clusteringCondition" :label="1" @change="radioChange($event, 'clusteringCondition')">普通团购</el-radio>
          <div class="ct-list" v-if="currentItem.clusteringCondition == '1'">
            <div class="ct-item flex-normal">
              <div class="item-col">
                <span class="col-txt">团购统一价</span>
              </div>
              <div class="item-col col-money">
                <el-input v-model="currentItem.groupBuyingPrice" placeholder="输入金额">
                  <span class="col-txt" slot="suffix">元</span>
                </el-input>
              </div>
            </div>
          </div>            
        </div>
        <div class="form-content-row flex-normal">
          <div class="warning-desc flex-normal">
            <i class="desc-icon el-icon-info"></i>
            <span class="desc-txt">活动达到新的阶梯时，付款差价将在活动结束时返还至用户账户</span>
          </div>
        </div>
      </el-form-item>
      <el-form-item v-if="activeFiles.remarks" class="form-content-item" :label="currentItem.activityTypeId == 7 ? '活动规则' : '活动描述'">
        <el-input type="textarea" :rows="8" 
        v-model="currentItem.remarks" 
        :placeholder="currentItem.activityTypeId == 7 ? '请设置活动规则' : '请输入活动描述'"
        ></el-input>
      </el-form-item>
    </el-form>
    <import-dialog ref="importDialog" title="导入用户" url="/system/acddUser/importUser"
    @import-success="importSuccess"/>
    <dialog-normal
      ref="dialog-price"
      :dialog-prop="{
        title: '活动结算',
        height: '55vh',
        width: '60%',
        submit: '支付并发布活动',
        close: ''
      }"
      @normal-submit="submitDialogPrice"
      >
      <template #dialog-content v-if="$refs[`dialog-price`] && $refs[`dialog-price`].showDialog">
        <div class="price-dialog-content flex-column">
          <span class="dialog-title">活动明细</span>
          <div class="row-item flex-normal">
            <div class="col-item flex-normal">
              <span class="col-label">活动编号</span>
              <span class="col-label">{{dialogPrice.baseData['activityCode']}}</span>
            </div>
          </div>
          <div class="row-item flex-normal">
            <div class="col-item flex-normal">
              <span class="col-label">活动类型</span>
              <span class="col-label">{{currentItem.activityTypeId | numToStr(dictsList, 'activityType')}}</span>
            </div>
          </div>
          <div class="row-item flex-normal">
            <div class="col-item flex-normal">
              <span class="col-label">活动份数</span>
              <span class="col-label">{{dialogPrice.baseData['number']}}份</span>
            </div>
          </div>
          <div class="row-item" v-if="tableData && tableData.length">
            <div class="col-rowcol-row">
              <div class="col-label" style="margin-bottom: 10px">服务明细</div>
              <div class="select-content">
                <el-table :data="tableData" style="width: 100%;">
                  <el-table-column prop="serveName" label="服务名称"></el-table-column>
                  <el-table-column prop="serveDetails" label="服务内容"></el-table-column>
                  <el-table-column prop="itemNum" label="数量">
                    <template slot-scope="{row}">
                      <div>{{ row.itemNum || '0' }}</div>
                    </template>
                  </el-table-column>
                  <el-table-column prop="price" label="价格"></el-table-column>
                  <el-table-column prop="writeOffFee" label="核销价"></el-table-column>
                  <el-table-column prop="total" label="总计"></el-table-column>
                </el-table>
              </div>
            </div>
          </div>
          <div class="row-item flex-normal gb">
            <div class="col-item flex-normal">
              <span class="col-label">技术服务费</span>
              <span class="col-label">{{dialogPrice.baseData['serveFee'] || '0.00'}}元</span>
            </div>
            <div class="col-item flex-normal">
              <span class="col-label">核销总计</span>
              <span class="col-label">{{dialogPrice.baseData['writeOffFee'] || '0.00'}}元</span>
            </div>
          </div>
          <div class="row-item flex-normal">
            <div class="col-item flex-normal">
              <span class="col-label">免付金额</span>
              <span class="col-label">{{dialogPrice.baseData['freePaymentAmount'] || '0.00'}}元</span>
            </div>
            <div class="col-item flex-normal">
              <span class="col-label">合计应付</span>
              <span class="col-label">{{dialogPrice.baseData['payableAmount']}}元</span>
            </div>
          </div>
        </div>
        <div class="LPay-code-container">
          <div class="flex-normal">
            <span class="Lpay-label">支付密码：</span>
            <div id="ipt_pwd" class="flex-normal ipt-pwd-content">
              <span id="LOGPASS_SHOW" class="placehoder-txt">请输入支付密码</span>
              <input id="LOGPASS" class="default input_search" type="password" disabled="disabled" />
              <div id="keyboardBtn" class="ipt_pwd_rjp default"></div>
            </div>
          </div>
        </div>
      </template>
    </dialog-normal>

    <dialog-normal
      ref="dialog-glfw" class="zjfw-dialog-content"
      :dialog-prop="{
        title: '管理自建服务',
        height: '55vh',
        width: '80%',
      }">
      <template #dialog-content v-if="$refs[`dialog-glfw`] && $refs[`dialog-glfw`].showDialog">
        <div class="zjfw-dialog-title flex-between">
          <span class="title-txt">自建服务</span>
          <el-button type="text" size="small" icon="el-icon-plus" @click="addFwItem">新增</el-button>
        </div>
        <div class="app-table-container" v-loading="glfwProps.loading">
          <el-table :data="glfwProps.list" border>
            <el-table-column
              label="服务类型"
              align="center"
              prop="serveTypeId">
              <template slot-scope="{row}">
                <template v-if="!row.isEdit">
                  {{ resetGlfwType(glfwProps.dictTypeList, row.serveTypeId) }}
                </template>
                <template v-else>
                  <el-cascader
                  v-model="row['serveTypeId']"
                  :options="glfwProps.dictTypeList"
                  placeholder="请选择服务类型"></el-cascader>
                </template>
              </template>
            </el-table-column>
            <el-table-column
              label="服务名称"
              align="center"
              prop="serveName">
              <template slot-scope="{row}">
                 <template v-if="!row.isEdit">
                  {{ row.serveName }}
                </template>
                <template v-else>
                  <el-input type="text" size="small" v-model="row.serveName" placeholder="服务名称"/>
                </template>
              </template>
            </el-table-column>
            <el-table-column
              label="服务明细"
              align="center"
              prop="serveDetails">
              <template slot-scope="{row}"> 
                <template v-if="!row.isEdit">
                  {{ row.serveDetails }}
                </template>
                <template v-else>
                  <el-input type="text" size="small" v-model="row.serveDetails" placeholder="输入服务明细"/>
                </template>
              </template>
            </el-table-column>
            <el-table-column
              label="服务次数"
              align="center"
              prop="itemNum">
              <template slot-scope="{row}">
                <template v-if="!row.isEdit">
                  {{ row.itemNum }}
                </template>
                <template v-else>
                  <el-input type="text" size="small" v-model="row.itemNum" placeholder="输入服务次数"/>
                </template>
              </template>
            </el-table-column>
            <el-table-column
              v-if="shopType == 4"
              label="用户优惠价"
              align="center"
              prop="discountedPrice">
              <template slot-scope="{row}"> 
                <template v-if="!row.isEdit">
                  {{ row.discountedPrice }}
                </template>
                <template v-else>
                  <el-input type="text" size="small" v-model="row.discountedPrice" placeholder="输入用户优惠价"/>
                </template>
              </template>
            </el-table-column>
            <el-table-column
              label="市场单价"
              align="center"
              prop="price">
              <template slot-scope="{row}"> 
                <template v-if="!row.isEdit">
                  {{ row.price }}
                </template>
                <template v-else>
                  <el-input type="text" size="small" v-model="row.price" placeholder="输入市场单价"/>
                </template>
              </template>
            </el-table-column>
            <el-table-column
              label="核销价"
              align="center"
              prop="writeOffFee">
              <template slot-scope="{row}">
                <template v-if="!row.isEdit">
                  {{ row.writeOffFee }}
                </template>
                <template v-else>
                  <el-input type="text" size="small" v-model="row.writeOffFee" placeholder="输入核销价"/>
                </template>
              </template>
            </el-table-column>
            <el-table-column
              label="操作"
              align="center"
              class-name="small-padding fixed-width"
            >
              <template slot-scope="{row,$index}">
                <el-button
                  size="mini"
                  type="text" v-if="!row.isEdit"
                  @click="editFwItem(row)"
                  >编辑</el-button>
                <el-button
                  size="mini"
                  type="text" v-else :loading="row.isSave"
                  @click="saveFwItem(row)"
                  >保存</el-button>
                <el-button
                  size="mini"
                  type="text"
                  @click="delFwItem(row, $index)"
                  >删除</el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </template>
    </dialog-normal>
    <dialog-normal
      ref="dialog-zhyz"
      :dialog-prop="{
        title: '账户验证',
        width: '500px',
        submit: '立即发布',
        close: '取消'
      }"
      @normal-submit="submitDialogCode">
      <template #dialog-content v-if="$refs[`dialog-zhyz`] && $refs[`dialog-zhyz`].showDialog">
        <el-input placeholder="请输入手机验证码" v-model="telCode"></el-input>
      </template>
    </dialog-normal>
  </div>
</template>

<script>
import {getNowDate, getPassYear, isPhoneNum} from '@/utils/tools.js'
import {
  addActivity, editActivity, getActiveFiles, getActivityDetail, getServeFee,
  priceCalculation,
} from "@/api/activeManage/active";
import { appModelList } from '@/formgen/components/FormConfig/config.js'
import {setH5Config} from '@/api/activeManage/active.js'
import validata from './validate'
import listData from './listData'
import priceVm from './price'
import { mapActions, mapGetters } from 'vuex';

export default {
  name: "List",
  mixins: [validata, listData, priceVm],
  components: {
    "dialog-normal": () => import("@/rhComponents/dialog/normal-dialog"),
    "import-dialog": () => import("@/rhComponents/dialog/import-dialog.vue"),
    'active-poster': () => import('@/rhComponents/active-poster/index.vue')
  },
  computed: {
    ...mapGetters(['shopType']),
    activeTypeDisabled(){
      let {id, activeType} = this.$route.query
      if(id) return true
      if(activeType) return true
      return false
    },
    hasPosterRef(){
      let {activityTypeId, id} = this.currentItem, boo = false
      if(activityTypeId == '2' || activityTypeId == '3' || activityTypeId == '4'  || activityTypeId == '7'){
        boo = true
      }
      if(id && boo === true) return true
      return false
    },
  },
  filters: {
    numToStr(num, list, type){
      let index = list.findIndex(item => item.name == type)
      if(index == -1) return '未定义参数'
      let idx = list[index].child.findIndex(i => i.dictValue == num)
      if(idx == -1) return '---'
      return list[index].child[idx].dictLabel
    }
  },
  data() {
    return {
      remarks:  '本活动支持随时退、过期退；\n'
          + '本活动如需要店激活，激活后不支持退款；\n'
          + '本活动为组合套餐活动，不支持部分退款；\n'
          + '本活动最终解释权归商家所有；',
      remarksCj: '抽奖产品有限，奖品全部抽完即止；\n'
          + '所有用户满足要求即可参与抽奖；\n'
          + '抽得奖品请及时到店使用，过期无效；\n'
          + '奖品若为实物类奖品，中奖用户需到店领取；\n'
          + '有任何疑问或障碍可直接拨打本店电话；\n'
          + '在法律允许范围内，本店拥有对本次活动的最终解释权。',
      boo: {
        loading: false,
        isPrice: false,
        isFlash: false,
        shopAll: false,
      },
      generateCardList: [], //新生成的卡券列表
      dictsList: [
        { label: "活动类型", name: "activityType", deptType: "activityType", child: [] },
        // { label: "技术服务费", name: "skillServeFee", deptType: "skillServeFee", child: [] },
        // { label: "奖励条件", name: "rewardCondition", deptType: "rewardCondition", child: [] },
        // { label: "到店激活", name: "shopActivation", deptType: "shopActivation", child: [] },
        { label: "商户池", name: "shopPool", deptType: "shopPool", child: [] },
        // { label: "自建/官方服务", name: "buildOneselfServe", deptType: "buildOneselfServe", child: [] },
      ],
      currentItem: {},
      activeFiles: {},
      dialogPrice: {
        baseData: {}
      }
    };
  },
  async mounted(){
    let _self = this, {id, activeType} = this.$route.query
    _self.queryServeTypeDict()
    _self.getServeList()
    _self.initGetDicts().then(async res => {
      await _self.setActivity(id)
      if(!id){
        let activeTypeItem = _self.getDictItem('activityType')[0] || {}
        _self.$set(_self.currentItem, 'activityTypeId', Number(activeType) || activeTypeItem.dictValue)
        _self.resetNewActive()
        _self.activeTypeChange()
      }else{
        let isSuccess = await _self.getActiveDetail(id)
        if(isSuccess){
          _self.activeTypeChange()
        }
      }
    })
  },
  methods: {
    ...mapActions(['setdrawingH5', 'setActivity']),
    async makePoster(){
      let _self = this, { id, activityName, activityTypeId } = this.currentItem
      const pageConf = JSON.parse(JSON.stringify(appModelList)).find(i => i.isDefault)
      let drawList = (pageConf.child || [])
      let params = {
        "activityId": id,
        "backgroundImg": pageConf.backgroundImg,
        "background": pageConf.background,
        "pageTitle": activityName,
        "pageDescribe": pageConf.pageDescribe,
        "modelName": pageConf.modelName || '', 
        "modelClass": pageConf.modelClass || '', 
        "draw": drawList.filter(i => i.isPoster).filter(item => {
          let {ignore} = item.config
          if((ignore || []).includes(`${activityTypeId}`)) return false
          return true
        })
      }
      _self.boo.isFlash = false
      _self.$nextTick(async () => {
        await _self.setdrawingH5(params)
        _self.boo.isFlash = true
        setTimeout(() => {
          _self.$nextTick(() => {
            let vmPoster = _self.$refs['posterRef']
            vmPoster.createPoster().then(async res => {
              params.firstScreenImg = res.url
              params.draw = drawList.filter(item => {
                let {ignore} = item.config
                if((ignore || []).includes(`${activityTypeId}`)) return false
                return true
              })
              await setH5Config(JSON.parse(JSON.stringify(params)))
            })
          })
        }, 1000)
      })
    },
    resetGlfwType(list, id){
      let emitItem = {}, arr = [], str = '---'
      list.forEach(item => {
        item.children.forEach(i => {
          i.labelStr = `${item.label}-${i.label}`
        })
        arr = [...arr, ...item.children]
      })
      emitItem = arr.find(i =>i.id == id)
      if(emitItem) return emitItem.labelStr
      return '---'
    },
    async getActiveDetail(id){
      if(!id) return
      let isSuccess = false, _self = this
      await getActivityDetail(id).then(res => {
        let {
          shopPool, suitShopIds,
          serveTypeIds, acddUsers = []
        } = res.data
        shopPool = shopPool ? shopPool.split(',') : []
        suitShopIds = suitShopIds ? suitShopIds.split(',') : []
        if(suitShopIds && suitShopIds.length){
          let maxLen = _self.shopList.length
          if(maxLen && suitShopIds.length == maxLen){
            _self.boo.shopAll = true
          } else {
            _self.boo.shopAll = false
          }
        }
        serveTypeIds = serveTypeIds ? serveTypeIds.split(',') : []
        _self.currentItem = res.data
        _self.currentItem.shopPool = shopPool
        _self.currentItem.suitShopIds = suitShopIds
        _self.currentItem.serveTypeIds = serveTypeIds
        _self.userList = acddUsers || []
        isSuccess = true
      })
      return isSuccess
    },
    resetNewActive(){
      let _self = this, {id} = this.$route.query
      let {activityTypeId} = _self.currentItem
      let actionsMap = () => {
        return new Map([
          [{id: '2', label: '定向优惠'}, async ()=>{
            if(!id){              
              let {activityTypeId, serviceFee} = _self.currentItem
              _self.currentItem = {activityTypeId, serviceFee, remarks: _self.remarks}
              _self.$set(_self.currentItem, 'activityName', '定向优惠')
              _self.$set(_self.currentItem, 'startingTime', getNowDate())
              _self.$set(_self.currentItem, 'endTime', getPassYear())
              _self.$set(_self.currentItem, 'whetherToClosingDate', true)
              _self.$set(_self.currentItem, 'skillServeFee', 1)
              let shopPools = _self.getDictItem('shopPool')
              if(shopPools[0]){
                _self.$set(_self.currentItem, 'shopPool', shopPools.map(i => i.dictValue))
              }
            }
            await _self.queryShopListByPool()
            await _self.getActiveDetail()
            _self.getServeList()
          }],
          [{id: '3', label: '特惠活动'}, async ()=>{
            if(!id){ 
              let {activityTypeId, serviceFee} = _self.currentItem
              _self.currentItem = {activityTypeId, serviceFee, remarks: _self.remarks}
              _self.$set(_self.currentItem, 'activityName', '特惠活动')
              _self.$set(_self.currentItem, 'startingTime', getNowDate())
              _self.$set(_self.currentItem, 'endTime', getPassYear())
              _self.$set(_self.currentItem, 'whetherToClosingDate', true)
              _self.$set(_self.currentItem, 'skillServeFee', 1)

              _self.$set(_self.currentItem, 'shopActivation', 1)
              _self.$set(_self.currentItem, 'activationStatus', 1)
              _self.$set(_self.currentItem, 'activationClosingDate', getPassYear())

              let shopPools = _self.getDictItem('shopPool')
              if(shopPools[0]){
                _self.$set(_self.currentItem, 'shopPool', shopPools.map(i => i.dictValue))
              }
            }
            await _self.queryShopListByPool()
            await _self.getActiveDetail()
            _self.getServeList()
          }],
          [{id: '4', label: '团购活动'}, async ()=>{
            if(!id){
              let {activityTypeId, serviceFee} = _self.currentItem
              _self.currentItem = {activityTypeId, serviceFee, remarks: _self.remarks}
              _self.$set(_self.currentItem, 'activityName', '团购活动')
              _self.$set(_self.currentItem, 'startingTime', getNowDate())
              _self.$set(_self.currentItem, 'endTime', getPassYear())
              _self.$set(_self.currentItem, 'whetherToClosingDate', true)
              _self.$set(_self.currentItem, 'skillServeFee', 1)

              _self.$set(_self.currentItem, 'shopActivation', 1)
              _self.$set(_self.currentItem, 'activationStatus', 1)
              _self.$set(_self.currentItem, 'activationClosingDate', getPassYear())
              _self.$set(_self.currentItem, 'clusteringCondition', 1)

              let shopPools = _self.getDictItem('shopPool')
              if(shopPools[0]){
                _self.$set(_self.currentItem, 'shopPool', shopPools.map(i => i.dictValue))
              }
            }
            await _self.queryShopListByPool()
            await _self.getActiveDetail()
            _self.getServeList()
          }],
          [{id: '5', label: '定向赠送'}, async ()=>{
            if(!id){
              let {activityTypeId, serviceFee} = _self.currentItem
              _self.currentItem = {activityTypeId, serviceFee, remarks: _self.remarks}
              _self.$set(_self.currentItem, 'activityName', '定向赠送')
              _self.$set(_self.currentItem, 'whetherToClosingDate', true)
              _self.$set(_self.currentItem, 'skillServeFee', 1)

              let shopPools = _self.getDictItem('shopPool')
              if(shopPools[0]){
                _self.$set(_self.currentItem, 'shopPool', shopPools.map(i => i.dictValue))
              }
            }            
            await _self.queryShopListByPool()
            await _self.getActiveDetail()
            _self.getServeList()
          }],
          [{id: '6', label: '现金红包'}, async ()=>{
            if(!id){
              let {activityTypeId, serviceFee} = _self.currentItem
              _self.currentItem = {activityTypeId, serviceFee}
              _self.$set(_self.currentItem, 'activityName', '现金红包')
              _self.$set(_self.currentItem, 'skillServeFee', 1)
            }           
            await _self.queryShopListByPool()
            _self.getActiveDetail()
          }],
          [{id: '7', label: '抽奖活动'}, async ()=>{
            if(!id){
              let {activityTypeId, serviceFee} = _self.currentItem
              _self.currentItem = {activityTypeId, serviceFee, remarks: _self.remarksCj}
              _self.$set(_self.currentItem, 'activityName', '抽奖活动')
              _self.$set(_self.currentItem, 'startingTime', getNowDate())
              _self.$set(_self.currentItem, 'endTime', getPassYear())
              _self.$set(_self.currentItem, 'whetherToClosingDate', true)
              _self.$set(_self.currentItem, 'skillServeFee', 1)
            }
            await _self.queryShopListByPool()
            await _self.getActiveDetail()
            _self.getServeList()
          }],
        ])
      }
      let actions = [...actionsMap()].filter(([key,value])=>(key.id == activityTypeId))
      actions.forEach(([key,value])=>value.call(this))
    },
    getDictItem(name){
      let item = this.dictsList.find(i => i.deptType == name)
      let idx = item.child.findIndex(i => (i.dictLabel == '内部发行卡券') || (i.dictLabel == '内部发行卡卷'))
      if(idx != -1){
        item.child.splice(idx, 1)
      }
      return item.child || []
    }, 
    async gePrice(activeId){
      let _self = this
      await _self.getRandom()
      await priceCalculation(activeId).then(res => {
        _self.dialogPrice.baseData = res.data
        _self.$refs['dialog-price'].showDialog = true
        _self.initPassword()
      })
    },
    isVehicleNumber(vehicleNumber) {
      // var xreg=/^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}(([0-9]{5}[DF]$)|([DF][A-HJ-NP-Z0-9][0-9]{4}$))/;
      var xxreg=/^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}(([0-9]{5}[DABCEFGHJK]$)|([DABCEFGHJK][A-HJ-NP-Z0-9][0-9]{4}$))/;  // 2021年新能源车牌不止有DF

      var creg=/^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳]{1}$/;

      if(vehicleNumber.length == 7){
        return creg.test(vehicleNumber);
      } else if(vehicleNumber.length == 8){
        return xxreg.test(vehicleNumber);
      } else{
        return false;
      }
    },
    submit(ref) {
      let _self = this;
      this.$refs[ref].validate(async (valid) => {
        if (valid) {
          let {activityTypeId, acddUsers} = _self.currentItem, { shopIds, targetedUsers } = _self.activeFiles
          let submitData = JSON.parse(JSON.stringify(_self.currentItem)), {id, type} = _self.$route.query
          submitData['serveTypeIds'] && (submitData['serveTypeIds'] = submitData['serveTypeIds'].join(','))
          if(targetedUsers){
            if(!acddUsers || !acddUsers.length) return _self.$message.error('请设置定向用户')
            let txtError = ''
            acddUsers.filter(i => i.useStatus == 1).forEach(i => {
              if(!i.name || i.name == '') {
                txtError = '请完善用户名称'
              }
              if(activityTypeId == 2){
                if(!_self.isVehicleNumber(i.licensePlate)){
                  txtError = '请填写正确车牌号，字母大写'
                }
                if(!i.orderTimeStart || i.orderTimeStart == '') {
                  txtError = '请完善定向开始时间'
                }
                if(!i.payValidDay || i.payValidDay == '') {
                  txtError = '请完善定向购买有效期'
                } 
                if(!i.orderPeriodValidity || i.orderPeriodValidity == '') {
                  txtError = '请完善定向卡券有效期'
                } 
              }
              if(!i.phone || i.phone == '' || !isPhoneNum(i.phone)) {
                txtError = '请输入正确格式的手机号'
              }
            })
            if(txtError) return _self.$message.error(txtError)
          }
          if(shopIds){
            submitData['shopPool'] && (submitData['shopPool'] = submitData['shopPool'].join(','))
            submitData['suitShopIds'] && (submitData['suitShopIds'] = submitData['suitShopIds'].join(','))
          }else{
            submitData['shopPool'] = ''
            submitData['suitShopIds'] = ''
          }
          if(activityTypeId == 7){
            submitData['serveList'] = _self.tableData.map(i => {
              return {
                id: i.id,
                probability: i.probability
              }
            })
          }
          _self.boo.isPrice = true
          if(!id){
            await addActivity(submitData).then(res => {
              _self.$message.success(res.msg)
              _self.$set(_self.currentItem, 'id', res.data)
              _self.makePoster()
              _self.gePrice(res.data)
            }).finally(() => {
              _self.boo.isPrice = false
            })
          }else{
            if(type == 'reset'){
              await addActivity(submitData).then(res => {
                _self.$message.success(res.msg)
                _self.$set(_self.currentItem, 'id', res.data)
                _self.makePoster()
                _self.gePrice(res.data)
              }).finally(() => {
                _self.boo.isPrice = false
              })
            }else{
              await editActivity(submitData).then(res => {
                _self.$message.success(res.msg)
                _self.gePrice(id)
              }).finally(() => {
                _self.boo.isPrice = false
              })
            }            
          }
          _self.boo.isPrice = false
        } else {          
          return false;
        }
      });
    },
    async activeTypeChange(){
      let _self = this
      let { activityTypeId } = _self.currentItem
      _self.boo.loading = true
      await getActiveFiles({activityTypeId}).then(res => {
        _self.activeFiles = res.data
      })
      await getServeFee(activityTypeId).then(res => {
        let {serveFee} = res.data
        _self.$set(_self.currentItem, 'serviceFee', serveFee)
      })
      _self.boo.loading = false
      _self.resetNewActive()
    },
    dataPickerChange(str, key){
      let _self = this
      if(key == 'closingDate'){
        if(str){
          _self.currentItem['whetherToClosingDate'] = false
        }else{
          _self.currentItem['whetherToClosingDate'] = true
        }
      }
    },
    checkboxChange(boo, key){
      let _self = this
      if(key == 'whetherToClosingDate'){
        if(boo){
          _self.currentItem['closingDate'] = ''
        }else{
          _self.currentItem['closingDate'] = _self.currentItem['endTime'] || ''
        }
      }
    },
    radioChange(val,key){
      let _self = this
      if(key == 'clusteringCondition'){
        let {acddGroupBuyings = []} = _self.currentItem
        if(val == '0' && !acddGroupBuyings.length){
          acddGroupBuyings.push({
            miniValue: '', 
            maxValue: '', 
            price: ''
          })
          _self.$set(_self.currentItem, 'acddGroupBuyings', acddGroupBuyings)
        }
      }
    },
    addGroupBuy(){
      this.currentItem.acddGroupBuyings.push({
        miniValue: '', 
        maxValue: '', 
        price: ''
      })
    },
    removeGroupBuy(idx){
      this.currentItem.acddGroupBuyings.splice(idx, 1)
    }
  }
};
</script>
<style scoped lang="scss">
@import './action-active.scss';
</style>